package com.cjg.Class;

import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.List;
import java.util.Map;

public class demo10 {
    public void test(Map<String,Student> map, List<Student> list){
        System.out.println("01");
    }
    public Map<String,Student> test02(){
        System.out.println("02");
        return null;
    }

    public static void main(String[] args) throws Exception {
        Method test = demo10.class.getMethod("test", Map.class, List.class);
        Type[] types = test.getGenericParameterTypes();
        for (Type type : types) {
            System.out.println(type);

            //ParameterizedType 参数化类型
            if (type instanceof ParameterizedType){
                Type[] types1 = ((ParameterizedType) type).getActualTypeArguments();
                for (Type type1 : types1) {
                    System.out.println(type1);
                }
            }
        }


        test = demo10.class.getMethod("test02");
        Type genericReturnType = test.getGenericReturnType();

        if (genericReturnType instanceof ParameterizedType){
            Type[] types1 = ((ParameterizedType) genericReturnType).getActualTypeArguments();
            for (Type type1 : types1) {
                System.out.println(type1);
            }
        }


    }


}
